
****************************************************** ANALYSIS FOR "Assessing Racial/Ethnic and Gender Gaps in Political Science PhD Students’ Methodological Self-efficacy", published 2021 in PS
****************************************************** BY Amy Erica Smith, Shauna Gillooly, and Heidi Hardt

****************************************************** Analysis by Amy Erica Smith. If you have questions about the analysis or data, please email me: amyericas@gmail.com

use "C:\Users\aesmith2\Dropbox\Work\research in progress\04 Gender Role Models\Data\Quant Survey Data\Public data\Grad_Experiences_Public_v1.dta", clear
cd "C:\Users\aesmith2\Dropbox\Work\research in progress\04 Gender Role Models\Analysis\P2 Race and Methods"

*************************** analysis of gender syllabus project survey

xtset universityid

**************** DVs
* quantitative methods
alpha q31_1 q31_2
alpha q31_3 q31_4
foreach var in q31_1 q31_2 q31_3 q31_4 {
	replace `var' = (`var'-1)/4
}

* program-related self-efficacy
alpha q28_*, item
egen programsuccess = rowmean(q28_*)
	replace programsuccess = (programsuccess-1)/4
alpha q28_2 q28_3 q28_3 q28_4 q28_5, item
egen programsuccess2 = rowmean(q28_2 q28_3 q28_3 q28_4 q28_5)
	replace programsuccess2 = (programsuccess2-1)/4
	
**************** demographics and role models
g year_in_program = q1
	lab var year_in_program "Year in Program"
recode q3 (21/25=1) (26/29=2) (30/35=3) (36/50=4), g(age)
	lab def age 1 "21-25" 2 "26-29" 3 "30-35" 4 "36-45", modify
	lab val age age
	lab var age "Age in Years"
recode q6 (2=0), g(firstgen)
	lab var firstgen "First Generation"
recode q43_1 (.=0), g(black)
recode q43_2 (.=0), g(latino)
recode q43_3 (.=0), g(white)
	lab def white 0 "Student of Color" 1 "White"
	lab val white white
recode q43_4 (.=0), g(asian)
recode q43_6 (.=0), g(mena)
recode q43_8 (.=0), g(other)
g race = 6 if white == 1
	replace race = 5 if latino == 1
	replace race = 4 if asian == 1
	replace race = 3 if other == 1
	replace race = 2 if black == 1
	replace race = 1 if mena == 1
lab def race 6 "White only" 5 "Latino/a" 2 "Black/African American" 4 "Asian" 1 "Middle Eastern/North African" 3 "Other Race/Ethnicity", modify
	lab val race race
recode q26 (2=0), g(haskids)
	lab var haskids "Has Dependents"
recode q4 (1 2 5 6 7 = 1) (3 4 = 0), g(haspartner) // Only two people said "other," & they both have partners.
	lab var haspartner "Has Partner"
*** gender
capture drop female
recode q2 (2=1) (1 = 0) (3 4 = .a) (5 = .), g(female)
	lab def female 0 "Male" 1 "Female" .a "Other/Nonbinary", modify
	lab val female female
recode q2 (1=1) (2=2) (3 4 = 3) (5=.), g(gender)
	lab def gender 1 "Male" 2 "Female" 3 "Other/Nonbinary", modify
	lab val gender gender

**** standardize program rank on a 0-1 scale
summ programrank
replace programrank = (programrank-r(min))/(r(max)-r(min))


*************************************************************************** main text ********************************************************************************************

**** initial bivariate analysis: text discussion
xtreg q31_2 b6.race, level(90) //demographics only
	margins race, level(90) //demographics only
xtreg q31_2 i.gender, level(90) //demographics only
	margins gender, level(90)

	
***************FIGURE 1: QUANT efficacy
xtreg q31_2 b6.race i.gender year_in_program i.age firstgen haskids haspartner programrank 
	margins race, level(90) //demographics only
	marginsplot, recast(bar) horizontal graphregion(lcolor(white) fcolor(white)) ysize(4) ///
		xscale(r(0)) ylabel(, nogrid) xlabel(0(.2)0.8) xmlabel(0(.1)0.8, nolabel grid gmax gmin) xsize(6) ///
		title("") xtitle("Quantitative Methods Self-efficacy (Predicted Values)") ytitle("") ///
		plotopts(lcolor(black) fcolor(dkorange) barwidth(.7) ) ciopts(lcolor(gs5))   
graph export Figure1.eps, cmyk(on) replace
		
************** TABLE 1. DETERMINANTS OF ACADEMIC SELF-EFFICACY
preserve
eststo clear
xtreg programsuccess b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank 
eststo
xtreg programsuccess b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank q31_2 q31_1 q31_4 q31_3 
eststo
esttab, b(2) se(2) star(* .10 ** .05 *** .01) label wide nopar
restore

*** are there differences in the effect of family status for women versus men? exploration
xtreg programsuccess b6.race 1.gender##haspartner 1.gender##haskids year_in_program i.age firstgen programrank 

 
**************************************************************** supplementary information ***********************************************************************************
 
**************************** supplementary information: summary statistics
summ programsuccess q31_2 q31_1 q31_4 q31_3

*************************** analysis of race
egen multiracial = anycount(q43_1 q43_2 q43_3 q43_4 q43_5 q43_6 q43_7 q43_8 ), values(1)
tab1 multiracial 
tab white multiracial, mi // 24 students were white and another race

****************** Figure S1: distribution of quantitative efficacy by race
twoway (histogram q31_2, percent width(.2) ), by(race, graphregion(fcolor(white) lcolor(white)) note("") norescale ) ///
	xtitle("Quantitative Methods Self-Efficacy") ytitle("Percentage") subtitle(, size(small))  ///
	xlabel(0.1 "0" 0.3 ".25" 0.5 ".5" 0.7 ".75" 0.9 "1.0") ylabel(0(15)45) xscale(r(0 1))

****************** Figure S2: gaps in quantitative efficacy appear to be stronger among women than men.
preserve
xtreg q31_2 b6.race##female //this is also table s3
	margins race#female, post
	parmest, norestore
egen race = seq(), f(1) t(6) block(2)	
	lab def race 6 "White only" 5 "Latino/a" 4 "Asian" 3 "Other Race/Ethnicity" 2 "Black/African American" 1 "Middle Eastern/North African", modify
	lab val race race
egen female = seq(), f(0) t(1)
	lab def female 0 "Male" 1 "Female", modify
	lab val female female
g xaxis = _n + (race-1)
	lab def xaxis  17 "White only" 14 "Latino/a" 11 "Asian" 8 "Other Race/Ethnicity" 5 "Black/African American" 2 "Middle Eastern/North African", modify
	lab val xaxis xaxis
graph twoway (bar estimate xaxis if female == 0, horizontal lcolor(black) fcolor(dkorange)) ///
			 (bar estimate xaxis if female == 1, horizontal lcolor(black) fcolor(dkgreen)) , ///
	ylabel(2(3)17,valuelabel angle(horizontal) notick nogrid) xscale(r(0)) graphregion(lcolor(white) fcolor(white)) ///
		xlabel(0(.2)0.8) xmlabel(0(.1)0.8, nolabel grid gmax gmin) ///
		title("") xtitle("Quantitative Methods Self-Efficacy") ytitle("") legend(order(1 "Male" 2 "Female"))
restore	
		
****************** Table S1: race*gender interaction
xtreg q31_2 b6.race##female

****************** FIGURE S3: quant interest
xtreg q31_1 b6.race i.gender, level(90) //demographics only
	margins race, level(90) //demographics only
	marginsplot, recast(bar) horizontal graphregion(lcolor(white) fcolor(white)) ///
		xscale(r(0)) ylabel(, nogrid) xlabel(0(.2)0.8) xmlabel(0(.1)0.8, nolabel grid gmax gmin) xsize(6) ///
		title("") xtitle("Quantitative Methods Interest") ytitle("") ///
		plotopts(lcolor(black) barwidth(.7) ) ciopts(lcolor(gs5)) 
	
****************** full models of quantitative efficacy
* Table S4
xtreg q31_2 b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank 
* Table S5
xtreg q31_2 b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank q31_1 q31_4 q31_3 

****************** FIGURE S4: QUAL
xtreg q31_4 b6.race, level(90) //demographics only
	margins race, level(90) //demographics only
	marginsplot, recast(bar) horizontal graphregion(lcolor(white) fcolor(white)) ///
		xscale(r(0)) ylabel(, nogrid) xlabel(0(.2)0.8) xmlabel(0(.1)0.8, nolabel grid gmax gmin) xsize(6) ///
		title("") xtitle("Qualitative Methods Self-Efficacy") ytitle("") ///
		plotopts(lcolor(black) fcolor(dkgreen) barwidth(.7) ) ciopts(lcolor(gs5)) name(efficacy, replace) fxsize(93)
xtreg q31_3 b6.race, level(90) //demographics only
	margins race, level(90) //demographics only
	marginsplot, recast(bar) horizontal graphregion(lcolor(white) fcolor(white)) ///
		xscale(r(0)) ylabel(, nogrid nolabel notick) xlabel(0(.2)0.8) xmlabel(0(.1)0.8, nolabel grid gmax gmin) xsize(6) ///
		title("") xtitle("Qualitative Methods Interest") ytitle("") ///
		plotopts(lcolor(black) fcolor(sienna) barwidth(.7) ) ciopts(lcolor(gs5)) name(interest, replace)
graph combine efficacy interest, col(2) xsize(6.5) ///
	graphregion(lcolor(none) fcolor(white))
	
****************** Table S6: full models of qualitative efficacy
eststo clear
xtreg q31_4 b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank 
eststo
xtreg q31_4 b6.race i.gender year_in_program i.age firstgen haskids##haspartner programrank q31_3
eststo
esttab, b(2) se(2) star(* .10 ** .05 *** .01) label wide nopar

